﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace CPPEI.Coolzon.UI.Views
{
    /// <summary>
    /// Interaction logic for DialogViewDecorator.xaml
    /// </summary>
    public partial class DialogViewDecorator : Window
    {
        public UI.View ContentView { get; set; }

        public DialogViewDecorator(View contentView)
        {
            InitializeComponent();

            ContentView = contentView;
            contentView.Close += contentView_Close;
            _ctlBorderContainer.Child = contentView;
        }

        private void _ctlBtnClose_Click_1(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
        }

        public void SetTitle(string title)
        {
            _ctlTextTitle.Text = title;
        }

        /// <summary>
        /// 是否显示右上角关闭按钮
        /// </summary>
        /// <param name="isShow"></param>
        public void ShowCloseButton(bool isShow)
        {
            if (isShow)
            {
                _ctlBtnClose.Visibility = System.Windows.Visibility.Visible;
            }
            else
            {
                _ctlBtnClose.Visibility = System.Windows.Visibility.Hidden;
            }
        }

        void contentView_Close(View view, bool isCancel)
        {
            if (DialogResult == null)
            {
                if (isCancel)
                {
                    DialogResult = false;
                }
                else
                {
                    DialogResult = true;
                }
            }
        }

        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                this.DragMove();
            }
            base.OnMouseMove(e);
        }
    }
}
